use crate::courier::codec::{EncodeError, DecodeError};

#[derive(Debug)]
pub enum CallError<Req> {
    Panic,
    TimeOut,
    RespLost,
    RespMismatch,
    LocalRequestServingTaskEnded(Req),
}

#[derive(Debug)]
pub enum Error<SE, DE> {
    Serialize(SE),
    Deserialize(DE),
    IO(std::io::Error),
}

impl<SE, DE> From<EncodeError<SE>> for Error<SE, DE> {
    fn from(value: EncodeError<SE>) -> Self {
        match value {
            EncodeError::IOError(e) => Self::IO(e),
            EncodeError::SerializeError(se) => Self::Serialize(se),
        }
    }
}
impl<SE, DE> From<DecodeError<DE>> for Error<SE, DE> {
    fn from(value: DecodeError<DE>) -> Self {
        match value {
            DecodeError::IOError(e) => Self::IO(e),
            DecodeError::DeserializeError(de) => Self::Deserialize(de),
        }
    }
}
